#!/bin/bash

#Post Commit script for this project.

# Important! the working copy in WWWREPOS must have been checked out by using a
# file:/// form, not in the http:// form otherwise the svn
# update will complain that it doesn't have the password for apache

# Important! No user should update manually the working copy in WWWREPOS, nor 
# work directly on it. Or at least, be very careful to leave the resulting files
# with ownership of apache.apache, otherwise, any subsequent update of those
# file or files will result in error

PATH=/bin:/usr/bin

# $1 contains the path to the svn repository
REPOS=`basename "$1"`

# The version number
REV="$2"

#Path in remote host where the local copy is
WWWREPOS="$3"

#Email to send a report of this transaction. Can contain several address, comma separated
MAILTO="$4"

cd $WWWREPOS || exit 1;
( svn log -r $2 ;
  echo -e "\n\n";
  svn update ;
  if [[ -f /usr/local/bin/svn-post-commit/$REPOS ]]; then . /usr/local/bin/svn-post-commit/$REPOS $WWWREPOS; fi;
  if [[ -f .svn-post-commit ]]; then . .svn-post-commit; fi;
) 2>&1 | mail $MAILTO -s "[SVN $REPOS] Commit of revision $REV"
